package com.airbnb.lottie.value;

import com.airbnb.lottie.utils.LinearCurve;
import ohos.agp.animation.Animator;

abstract class LottieInterpolatedValue<T> extends LottieValueCallback<T> {
    private T startValue = null;

    private T endValue = null;

    private Animator.TimelineCurve interpolator = null;

    LottieInterpolatedValue(T startValue, T endValue) {
        this(startValue, endValue, new LinearCurve());
    }

    LottieInterpolatedValue(T startValue, T endValue, Animator.TimelineCurve interpolator) {
        this.startValue = startValue;
        this.endValue = endValue;
        this.interpolator = interpolator;
    }

    @Override
    public T getValue(LottieFrameInfo<T> frameInfo) {
        float progress = interpolator.getCurvedTime(frameInfo.getOverallProgress());
        return interpolateValue(startValue, endValue, progress);
    }

    abstract T interpolateValue(T startValue, T endValue, float progress);
}
